Claude Code Sub Agent Knowledge Base Management System
Introduction
This tutorial demonstrates a simple method to create a multi-agent knowledge management system using Claude Code's [sub agents capabilities](https://docs.anthropic.com/en/docs/claude-code/sub-agents. With just a few prompts, Claude Code will create five specialized agents that transform your Obsidian vault maintenance from hours of manual work into a simple command: "Run vault enhancement".
Watch the Build Process
Watch this demonstration of the multi-agent vault enhancement system:
What You'll Build
A complete knowledge management system with five specialized agents working in parallel to optimize your Obsidian vault.
You Will Need
- Claude Code installed
- Anthropic Claude subscription or pre-purchased API credits
Install Claude Code
npm install -g @anthropic-ai/claude-code
1. Getting Started
- Start a Claude Code session in your Obsidian vault directory
- Create the CLAUDE.md project file and .claude folder by running /init once Claude Code has started
/init
Initial Request
"I have an Obsidian vault with thousands of files. It's gotten messy - inconsistent tags, missing metadata, orphaned notes with no connections. Let's build a team of specialized sub agents that can work together as a team to manage Obsidian going forward. Next I'll start creating agents using the /agents method."
2. Create the Sub Agents
Use the /agents
command and configure the options shown below for each agent:
/agents
Create new agent
Project (.claude/agents/)
Generate with Claude
Describe what this agent should do and when it should be used, for example "Agent that normalizes and hierarchically organizes the tag taxonomy".
For this tutorial, we'll simply copy and paste the information provided below for each agent.
The Agent Team
1. Metadata Agent (metadata-agent
)
Purpose: Ensures every file has proper frontmatter metadata
Responsibilities:
- Scans all markdown files for missing frontmatter
- Adds standardized metadata structure including:
- Tags (based on directory structure)
- Type (note, reference, moc, etc.)
- Creation/modification dates
- Status (active, archive, draft)
- Related files and aliases arrays
- Maintains 100% metadata compliance
Tools Used:
- Python script:
metadata_adder.py
- Filesystem analysis for date extraction
- Directory-based tag generation
2. Connection Agent (connection-agent
)
Purpose: Discovers potential links between related content
Responsibilities:
- Analyzes all notes for entity mentions (people, companies, technologies)
- Identifies keyword overlap between documents
- Finds orphaned notes with no connections
- Generates comprehensive link suggestion reports
- Prioritizes connections by confidence and value
Discovery Methods:
- Entity extraction (names, products, companies)
- Semantic similarity analysis
- Common keyword identification
- Directory proximity considerations
Tools Used:
- Python script:
link_suggester.py
- Natural language processing for entity recognition
- Keyword frequency analysis
3. Tag Agent (tag-agent
)
Purpose: Maintains a clean, hierarchical tag taxonomy
Responsibilities:
- Normalizes technology names (e.g., "langchain" → "LangChain")
- Applies hierarchical structure (e.g., "ai/agents", "business/strategy")
- Consolidates duplicate and similar tags
- Ensures consistent formatting
- Generates tag analysis reports
Standardization Rules:
- Maximum 3-level hierarchy
- Forward slashes for categories
- Proper case for product names
- Hyphens for multi-word tags
Tools Used:
- Python script:
tag_standardizer.py
- PyYAML for frontmatter manipulation
- Taxonomy mapping system
4. MOC Agent (moc-agent
)
Purpose: Creates and maintains Maps of Content for navigation
Responsibilities:
- Identifies directories without MOCs
- Generates MOCs using standardized templates
- Organizes orphaned images into galleries
- Updates master navigation structures
- Ensures all content is discoverable
MOC Standards:
- Centralized in
/map-of-content/
directory - Named as "MOC - [Topic].md"
- Includes overview, resources, and connections
- Links bidirectionally with content
Tools Used:
- Python script:
moc_generator.py
- Template-based generation
- Directory structure analysis
5. Review Agent (review-agent
)
Purpose: Quality assurance and validation
Responsibilities:
- Validates all changes made by other agents
- Checks for consistency across enhancements
- Identifies potential issues or conflicts
- Generates vault maturity score
- Provides actionable recommendations
Review Checklist:
- Metadata compliance
- Connection relevance
- Tag hierarchy adherence
- MOC completeness
- Overall vault health metrics
3. Essential Prompts - Validation and Customization
Testing Individual Agents
Test each agent individually to ensure they're working correctly
Creating the Orchestration
Create a way to run all agents asynchronously when I say "Run vault enhancement"
The Enhancement Workflow
When you trigger the system with "Run vault enhancement", Claude Code orchestrates:
1. Trigger Phase
User says: "Run vault enhancement"
2. Orchestration Phase
Claude Code:
- Loads all five sub-agent configurations from
.claude/agents/
- Creates a todo list for tracking progress
- Invokes agents in parallel for efficiency
3. Execution Phase
Each agent independently:
- Analyzes their specific domain
- Runs their specialized Python scripts
- Makes necessary changes
- Generates reports
4. Review Phase
The review agent:
- Validates all changes
- Checks cross-agent consistency
- Calculates vault maturity score
- Identifies any issues
5. Reporting Phase
System generates:
- Individual agent reports
- Consolidated enhancement report
- Actionable recommendations
- Success metrics
Advanced Usage
Targeted Enhancements
Run vault enhancement on /Projects/AI-Research
Run metadata agent and tag agent on my daily notes folder
Enhance files modified in the last week
Custom Workflows
Run morning vault cleanup (only orphaned notes and quick metadata fixes)
Prepare research notes for presentation (generate MOCs and connection maps)
Interactive Mode
Run vault enhancement in preview mode
Show me tag consolidation suggestions and let me choose
Sub Agent Configuration
Sub agents are stored as Markdown files with YAML frontmatter in:
Type | Location | Scope | Priority |
---|---|---|---|
Project sub agents | .claude/agents/ | Available in current project | Highest |
User sub agents | ~/.claude/agents/ | Available across all projects | Lower |
Beyond Vault Management
The same approach works for:
- Code Review System: Multiple agents checking different aspects
- Research Assistant: Literature review, citation management, synthesis
- Content Pipeline: Writing, editing, SEO optimization, publishing
- Data Analysis: Cleaning, analyzing, visualizing, reporting
- DevOps Automation: Testing, deployment, monitoring, alerting
For more information about Claude Code and sub agents, visit the [official documentation](https://docs.anthropic.com/en/docs/claude-code/sub-agents.